﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using MusicDatabase.Models;
using MusicDatabase.ViewModels;

namespace MusicDatabase.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        MusicStoreEntities storeDB = new MusicStoreEntities();

        public ActionResult Index(string genre = "Rock")
        {
            // Retrieve Genre from database
            var genreModel = storeDB.Genres.Include("Albums")
                .Single(g => g.Name == genre);

            var viewModel = new StoreBrowseViewModel()
            {
                Genre = genreModel,
                Albums = genreModel.Albums.ToList()
            };

            return View(viewModel);
        }

       
    }
}
